﻿#region

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

#endregion


namespace OMS.Ice.T4Generator.Tutorial
{
    internal class Part2
    {
        public static void Generate()
        {
            IGenerator generator = new Generator();

            var stream = new MemoryStream();
            var textWriter = new StreamWriter( stream );

            IList<string> friends = new List<string> {"Mary", "Peter", "Paul"};
            generator.Generate(textWriter, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Part2\Part2.t4"), friends);

            stream.Seek( 0, SeekOrigin.Begin );
            var textReader = new StreamReader( stream );

            var generatedText = textReader.ReadToEnd();
        }

    }

    public static class GeneratorExtension
    {
        public static void Generate(this IGenerator generator, TextWriter output, string template, IList<string> friends)
        {
            generator.Generate( template, output, friends );
        }
    }
}
